package com.visionet.school.app.web.repository.user;

import com.visionet.school.app.web.entity.user.User;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

/**
 * Created by hxpeng on 2017/3/9.
 */
@Repository
public interface UserRepository extends PagingAndSortingRepository<User,String>,JpaSpecificationExecutor<User> {

    @Query("from User as u where u.loginName = ?1 and u.password = ?2 and u.isDeleted = '0' ")
    User login(String userName, String userPwd);

    @Query("from User as u where u.isDeleted = '0' and u.loginName = ?1 and u.status = 'normal' and u.loginType = 'wechat' ")
    User findOneByOpenId(String openId);

    @Query("from User as u where u.memberId = ?1 and u.isDeleted = '0' ")
    User findOneByMemberId(String memberId);

}
